package com.qf.controller;

import com.github.pagehelper.PageInfo;
import com.qf.entity.Testlxf;
import com.qf.service.TestLxfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 2020/1/7
 * 键盘敲烂，月薪过万
 * 登高必自卑，行远必自迩。
 * 不忘初心：像初学者一样拥有一颗谦虚、开放的心态。
 * 李学峰
 */
@Controller
public class TestLxfController {
@Autowired
    private TestLxfService testLxfService;
@RequestMapping("/getall")
    public String getall(ModelMap map,
                         @RequestParam(defaultValue = "1")int page,
                         @RequestParam(defaultValue = "2") int size,
                         String course,
                         String tname){
    PageInfo<Testlxf> findall = testLxfService.findall(page, size, course, tname);
    PageInfo<Testlxf> findalla = testLxfService.findall(page, size, course, tname);
    map.addAttribute("all",findall);
    map.addAttribute("all1",findalla);
    map.addAttribute("course",course);
    map.addAttribute("tname",tname);
    return "index";

}
@RequestMapping("/updateA")
    public String a(int tid,ModelMap map){
    Testlxf testlxf = testLxfService.selectByid(tid);
    map.addAttribute("up",testlxf);
    return "update";

}

    @RequestMapping("/updataB")
    public String updataA(Testlxf testlxf){
        int i = testLxfService.updata(testlxf);
        System.out.println(i);
        if (i>0){
            return "redirect:getall";
        }
        return "updateA";
    }



}
